package net.admin.action;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.admin.db.item.ItemDAO;

public class ItemSearchAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ActionForward af = new ActionForward();
		ArrayList list = null;
		ItemDAO dao = null;
		boolean result=false;
		af.setRedirect(false);
		af.setPath("/admin/item/item_search.jsp");
		String itemName = request.getParameter("itemName");
		String category_nm = request.getParameter("category_nm");
		try{
			dao = new ItemDAO();
			list=dao.getItemList(itemName,category_nm);
			request.setAttribute("result", "Y");
			request.setAttribute("list", list);
		}catch(Exception e){
			e.printStackTrace();
			result=false;
			request.setAttribute("result", "N");
		}finally{
			dao.close();
		} 
		
		return af;
	}

}
